const path = require('path')

//导入在内存中生成HTML页面的插件
const htmlWebpackPlugin = require("html-webpack-plugin")

const { VueLoaderPlugin } = require('vue-loader')

module.exports = {
    mode: 'production',
    entry: path.join(__dirname, './src/main.js'),
    output: {
        path: path.join(__dirname, './dist'),
        filename: 'bundle.js',
    },
    module: {
        rules: [//配置规则
            { test: /\.css$/, use: ['style-loader', 'css-loader'] },
            { test: /\.less$/, use: ['style-loader', 'css-loader', 'less-loader'] },
            { test: /\.scss$/, use: ['style-loader', 'css-loader', 'sass-loader'] },
            { test: /vue-preview.src.*?js$/, use: 'babel-loader' },
            { test: /\.(jpg|png|gif|bmp|jpeg)$/, use: 'url-loader?limit=40000' },
            { test: /\.(ttf|eot|svg|woff|woff2)$/, use: 'url-loader' },
            { test: /\.vue$/, use: 'vue-loader' },
            { test: /\.js$/, use: 'babel-loader', exclude: /node_modules/ }
            
        ]
    },
    plugins: [//配置插件节点
        new htmlWebpackPlugin({//创建在内存中生成HTML页面的插件
            template: path.join(__dirname, './src/index.html'),//指定模板页面
            filename: 'index.html'

        }),

        new VueLoaderPlugin()

    ]
}